package com.cssy.yd.basic.dao.impl;

import com.cssy.yd.basic.dao.BasicAreaDAO;
import com.cssy.yd.basic.entity.BasicAreaDO;
import com.cssy.yd.basic.entity.BasicStorageinfoTypeDO;
import com.plat.helper.SearchConditions;

import java.util.List;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

/**
 * 数据访问对象实现类
 * @since 2013-06-21
 */
public class BasicAreaDAOImpl extends SqlMapClientDaoSupport implements BasicAreaDAO {

    /**
     * 插入数据
     * @param basicAreaDO
     * @return 插入数据的主键
     */
    public String insertBasicAreaDO(BasicAreaDO basicAreaDO) throws DataAccessException {
        Object id = getSqlMapClientTemplate().insert("BasicArea.insert", basicAreaDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param basicAreaDO
     * @return 查出的记录数
     */
    public Integer countBasicAreaDOByExample(BasicAreaDO basicAreaDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("BasicArea.countByDOExample", basicAreaDO);
        return count;
    }

    /**
     * 更新记录
     * @param basicAreaDO
     * @return 受影响的行数
     */
    public Integer updateBasicAreaDO(BasicAreaDO basicAreaDO) throws DataAccessException {
        int result = getSqlMapClientTemplate().update("BasicArea.update", basicAreaDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param basicAreaDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<BasicAreaDO> findListByExample(BasicAreaDO basicAreaDO) throws DataAccessException {
        List<BasicAreaDO> list = getSqlMapClientTemplate().queryForList("BasicArea.findListByDO", basicAreaDO);
        return list;
    }

    /**
     * 根据主键获取basicAreaDO
     * @param id
     * @return basicAreaDO
     */
    public BasicAreaDO findBasicAreaDOByPrimaryKey(String id) throws DataAccessException {
        BasicAreaDO basicAreaDO = (BasicAreaDO) getSqlMapClientTemplate().queryForObject("BasicArea.findByPrimaryKey", id);
        return basicAreaDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteBasicAreaDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("BasicArea_ex.deleteById", id);
        return rows;
    }

    @Override
	public List<BasicAreaDO> find(SearchConditions scs)
			throws DataAccessException {
		List<BasicAreaDO> list = getSqlMapClientTemplate().queryForList("BasicArea_ex.find", scs);
		return list;
	}

	@Override
	public Integer count(SearchConditions scs) throws DataAccessException {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("BasicArea_ex.count", scs);
		return count;
	}
}